<template>
  <div>
    <div class="xjshdzy" @click="fanhuidz">
        新建收货地址
    </div>
  <van-address-edit
  :area-list="areaList"
  show-postal
  show-delete
  show-set-default
  show-search-result
  :search-result="searchResult"
  :area-columns-placeholder="['请选择', '请选择', '请选择']"
  @save="onSave"
  @delete="onDelete"
  @change-detail="onChangeDetail"
  :address-info="{
        name: info.name,
        tel: info.tel,
        addressDetail: info.addressDetail,
        areaCode: info.areaCode,
        postalCode: info.postalCode,
        isDefault: info.isDefault,
      }"
  />
  </div>
</template>

<script>
import { Toast } from 'vant';
import { areaList } from '@vant/area-data';
export default {
  data() {
    return {
      areaList,
      searchResult: [],
      info: [],
      uname: sessionStorage.getItem("uname"),
    };
  },
  methods: {
    fanhuidz(){
      this.$router.push("/duihuan").catch(err=>err)
    },
    onSave(content) {
      Toast('save');
      this.$http({
            url:"http://localhost:3000/gwcxx",
            method:"post",
            data:{
                name:content.name,
                phone:content.tel,
                province:content.province,
                city:content.city,
                county:content.county,
                detail_addr:content.addressDetail,
                areaCode:content.areaCode,
                postalCode:content.postalCode
                }            
             }).then(res=>{
                // console.log(res.data);
            }),
           this.$router.push("/duihuan").catch(err=>err)
    },
    onDelete() {
      Toast('delete');
    },
    onChangeDetail() {
    },
  },
};
</script>

<style scoped>
.xjshdzy{
  width: 100vw;
  height: 13vw;
  text-align: center;
  line-height: 13vw;
}
</style>